<?php
	require 'model/reqveiculo.php';
	//require 'controller/controller.php';
	require 'banco.php';
	function dateFormatBrazil($date){
		//recebe o parâmetro e armazena em um array separado por -
		$date = explode('-', $date);
		$date = $date[2].'/'.$date[1].'/'.$date[0];
		//retorna a string com a data na ordem correta e formatada
		return $date;
	}
	
	session_start();
	//echo $_SESSION['iden'];
	$id = $_SESSION['iden'];
	//session_destroy();
	
	//$contro = new ControllerReqServico;
	//$data = $contro->retornaReqServico($id);
	$banco = new Banco();
	$data = $banco->retornaReqVeiculo($id);
	$solicitante = $data['solicitante'];
	$matricula = $data['matricula'];
	$datareq = $data['data'];
	$cargo = $data['cargo'];
	$email = $data['email'];
	$setor = $data['setor'];
	$ramal = $data['ramal'];
	$roteiro = $data['roteiro'];
	$finalidade = $data['finalidade'];
	$passageiros = $data['passageiros'];
	$id_reserva = $data['idreserva'];
	
	$data = $banco->retornaReserva($id_reserva);
	$veiculo = $data['veiculo'];
	$data_hora_ida = $data['data_hora_ida'];
	list( $date, $time ) = explode( ' ', $data_hora_ida);
	$date_ida = dateFormatBrazil($date);
	list($time, $time2, $time3) = explode(':',$time);
	$time_ida = $time.':'.$time2;
	
	$data_hora_volta = $data['data_hora_volta'];
	list( $date, $time ) = explode( ' ', $data_hora_volta);
	$date_volta = dateFormatBrazil($date);
	list($time, $time2, $time3) = explode(':',$time);
	$time_volta = $time.':'.$time2;
	
	
	$_SESSION['identificador'] = $id;
	$_SESSION['solicitante'] = $solicitante;
	$_SESSION['matricula'] = $matricula;
	$_SESSION['data'] = $datareq;
	$_SESSION['cargo'] = $cargo;
	$_SESSION['email'] = $email;
	$_SESSION['setor'] = $setor;
	$_SESSION['ramal'] = $ramal;
	$_SESSION['roteiro'] = $roteiro;
	$_SESSION['finalidade'] = $finalidade;
	$_SESSION['passageiros'] = $passageiros;
	
	$_SESSION['veiculo'] = $veiculo;
	$_SESSION['data_ida'] = $date_ida;
	$_SESSION['time_ida'] = $time_ida;
	$_SESSION['data_volta'] = $date_volta;
	$_SESSION['time_volta'] = $time_volta;
	
	function gerarPdf(){
		header('Location: requerimento_pdf_veiculo.php');
	}
?>

<!DOCTYPE html>
<html lang="en">
<head>
	
  <meta charset="utf-8">
  <title>Requerimento de Veículo</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="description" content="">
  <meta name="author" content="">

	<link href="css/bootstrap.min.css" rel="stylesheet">
	<link href="css/style.css" rel="stylesheet">

  <!-- Fav and touch icons -->
  <link rel="apple-touch-icon-precomposed" sizes="144x144" href="img/apple-touch-icon-144-precomposed.png">
  <link rel="apple-touch-icon-precomposed" sizes="114x114" href="img/apple-touch-icon-114-precomposed.png">
  <link rel="apple-touch-icon-precomposed" sizes="72x72" href="img/apple-touch-icon-72-precomposed.png">
  <link rel="apple-touch-icon-precomposed" href="img/apple-touch-icon-57-precomposed.png">
  <link rel="shortcut icon" href="img/favicon.ico">
  
	<script type="text/javascript" src="js/jquery.min.js"></script>
	<script type="text/javascript" src="js/bootstrap.min.js"></script>
	<script type="text/javascript" src="js/scripts.js"></script>
</head>

<body>
<div class="panel panel-default">
				<div class="panel-heading">
					<h3 class="panel-title">
						<span class="glyphicon glyphicon-user"></span> <strong>Solicitação Realizada</strong>
					</h3>
				</div>
				<div class="panel-body">
			<form role="form" class="form-horizontal" method="POST" name="form1" action="controller/controller.php" onsubmit="return limpaForm();">
				<div class="form-group">
					 <label class="col-sm-2"><font color='red'>ID: <?php echo $id?></font><font> | <a href="requerimento_pdf_veiculo.php">Gerar PDF</a></font></label>
				</div>
				
				<div class="form-group">
					<label class="col-sm-2 control-label">Solicitante</label>
					<div class="col-sm-7">
						<input type="text" class="form-control" name="solicitante" maxlength="100" value="<?php echo $solicitante?>" readonly />
					</div>
					<label class="col-sm-1 control-label">Matrícula</label>
					<div class="col-sm-2">
						<input type="text" class="form-control" name="matricula" maxlength="8" onkeypress='return SomenteNumero(event)' value="<?php echo $matricula?>" readonly >
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">Cargo</label>
					<div class="col-sm-3">
						<input type="text" class="form-control" name="cargo" maxlength="50" value="<?php echo $cargo?>" readonly >
					</div>
					<label class="col-sm-1 control-label" for="exampleInputEmail1">Email</label>
					<div class="col-sm-6">
						<input type="email" class="form-control" id="exampleInputEmail1" name="email"  value="<?php echo $email?>" readonly />
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">Setor</label>
					<div class="col-sm-3">
						<input type="text" class="form-control" name="setor" maxlength="50" value="<?php echo $setor ?>" readonly >
					</div>
					<label class="col-sm-1 control-label">Ramal</label>
					<div class="col-sm-6">
						<input type="text" class="form-control" name="ramal" maxlength="4" onkeypress='return SomenteNumero(event)' value="<?php echo $ramal ?>" readonly />
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">Veículo</label>
					<div class="col-sm-3">
						<input type="text" class="form-control" name="veiculo" maxlength="30" value="<?php echo $veiculo?>" readonly />
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">Data de Partida</label>
					<div class="col-sm-4">
						<input type="text" class="form-control" name="data_ida" maxlength="30" value="<?php echo $date_ida?>" readonly />
					</div>
					<label class="col-sm-2 control-label">Hora de Partida</label>
					<div class="col-sm-4">
						<input type="text" class="form-control" name="time_ida" maxlength="30" value="<?php echo $time_ida?>" readonly />
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">Data de Chegada</label>
					<div class="col-sm-4">
						<input type="text" class="form-control" name="data_volta" maxlength="30" value="<?php echo $date_volta?>" readonly />
					</div>
					<label class="col-sm-2 control-label">Hora de Chegada</label>
					<div class="col-sm-4">
						<input type="text" class="form-control" name="time_volta" maxlength="30" value="<?php echo $time_volta?>" readonly />
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">Roteiro</label>
					<div class="col-sm-10">
						<input type="text" class="form-control" name="roteiro" maxlength="50" value="<?php echo $roteiro?>" readonly  >
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">Finalidade</label>
					<div class="col-sm-4">
						<input type="text" class="form-control" name="finalidade" maxlength="50" value="<?php echo $finalidade?>" readonly  >
					</div>
					<label class="col-sm-3 control-label">Quantidade de Passageiros</label>
					<div class="col-sm-3">
						<input type="text" class="form-control" name="passageiros" maxlength="50" value="<?php echo $passageiros?>" readonly  >
					</div>
				</div>
			</form>
				</div>
			</div>
		<div class="panel-footer">
					<small><p class="text-right text-muted">Desenvolvido pela <a href="http://www.ifsertao-pe.edu.br/dgti" target="_blank" title="Coordenação de Tecnologia da Informação">CTI</a></p></small>
		</div>
	</div>
</body>
</html>
